

package com.loong.loong.hik.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.loong.loong.common.core.util.R;
import com.loong.loong.common.log.annotation.SysLog;
import com.loong.loong.hik.entity.HikCdcTerminal;
import com.loong.loong.hik.service.HikCdcTerminalService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.loong.loong.common.excel.annotation.ResponseExcel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 疾控终端
 *
 * @author 疾控终端
 * @date 2023-04-23 10:10:09
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/hikcdcterminal" )
@Api(value = "hikcdcterminal", tags = "疾控终端管理")
public class HikCdcTerminalController {

    private final  HikCdcTerminalService hikCdcTerminalService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param hikCdcTerminal 疾控终端
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('hik_hikcdcterminal_view')" )
    public R getHikCdcTerminalPage(Page page, HikCdcTerminal hikCdcTerminal) {
        return R.ok(hikCdcTerminalService.page(page, Wrappers.query(hikCdcTerminal)));
    }


    /**
     * 通过id查询疾控终端
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('hik_hikcdcterminal_view')" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(hikCdcTerminalService.getById(id));
    }

    /**
     * 新增疾控终端
     * @param hikCdcTerminal 疾控终端
     * @return R
     */
    @ApiOperation(value = "新增疾控终端", notes = "新增疾控终端")
    @SysLog("新增疾控终端" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('hik_hikcdcterminal_add')" )
    public R save(@RequestBody HikCdcTerminal hikCdcTerminal) {
        return R.ok(hikCdcTerminalService.save(hikCdcTerminal));
    }

    /**
     * 修改疾控终端
     * @param hikCdcTerminal 疾控终端
     * @return R
     */
    @ApiOperation(value = "修改疾控终端", notes = "修改疾控终端")
    @SysLog("修改疾控终端" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('hik_hikcdcterminal_edit')" )
    public R updateById(@RequestBody HikCdcTerminal hikCdcTerminal) {
        return R.ok(hikCdcTerminalService.updateById(hikCdcTerminal));
    }

    /**
     * 通过id删除疾控终端
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除疾控终端", notes = "通过id删除疾控终端")
    @SysLog("通过id删除疾控终端" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('hik_hikcdcterminal_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(hikCdcTerminalService.removeById(id));
    }


    /**
     * 导出excel 表格
     * @param hikCdcTerminal 查询条件
     * @return excel 文件流
     */
    @ResponseExcel
    @GetMapping("/export")
    @PreAuthorize("@pms.hasPermission('hik_hikcdcterminal_export')" )
    public List<HikCdcTerminal> export(HikCdcTerminal hikCdcTerminal) {
        return hikCdcTerminalService.list(Wrappers.query(hikCdcTerminal));
    }
}
